<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>资产管理</title>
	<meta name="decorator" content="default"/>
	<link rel="stylesheet" type="text/css" href="${ctxStatic}/userstatic/css/chs-alert.css"/>
	<!--artTemplate插件-->
	<script src="${ctxStatic}/userstatic/js/template.js" type="text/javascript" charset="utf-8"></script>
	<!--弹窗插件-->
	<script src="${ctxStatic}/userstatic/js/chs-alert.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
	var staticData = null;
	$(function(){
		//本地为了测试的json数据，上线后请删除
		staticData = (function(){
			var data = [];
			for (var i = 0; i < 100; i ++) {
				data.push({
					name: '重庆麻麻鱼火锅底料'+i,
					code: 'DAFAW3134'+i,
					stock: '33'+i,
					dateTime: '2017-11-06 12:11:01',
					wares: '免费仓'+i
				})
			}
			return data;
		})();
		
		//实例化弹窗类，下列参数必须传入
		var myalert = new chs_alert({
			handle: '#alertHandle',//触发弹窗的元素
			eventStr: 'click',//触发弹窗的事件，
			ajaxUrl: '${ctx}/guobo/asset/searchNCAseets',//弹窗列表数据的ajax请求地址
			title: '资产列表',//弹窗的title显示
			callback: function(data){ //当点击列表触发的回调函数，会传回点击的项对应的数据				
				console.log(data);
				$('input[name=code]').val(data.code);
				$('input[name=name]').val(data.name);
				$('input[name=spec]').val(data.spec);
				$('input[name=type]').val(data.type);
				$('input[name=typeName]').val(data.typeName);
				$('input[name=model]').val(data.model);
				$('input[name=managerId]').val(data.managerId);
				$('input[name=managerName]').val(data.managerName);
				$('input[name=mobile]').val(data.mobile);
				$('input[name=mandeptId]').val(data.mandeptId);
				$('input[name=mandeptName]').val(data.mandeptName);
			}
		})
	})
	</script>
	<script type="text/javascript">
		$(document).ready(function() {
			var isParentRfid = '${asset.isParentRfid}';
			if(isParentRfid=="N" || isParentRfid=="" || isParentRfid==null){
				$("#parentRfid").hide();
			}
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			
			$("#isParentRfid").change(function(){
				var type = this.value;
				if(type=='Y'){
					$("#parentRfid").show();
				}
				if(type=='N'){
					$("#parentRfid").hide();
				}
			});
			
		});
	</script>
	<!--弹窗的模板-->
	<script id="chs-alert-temp" type="text/html">
		<div class="chs-alert-cover">
			<div class="chs-alert-box">
				<div class="chs-alert-head">
					{{title}}
					<div class="chs-alert-close">×</div>
				</div>
				<div class="chs-alert-top-search">
					设备名称：<input name="matrial_name" type="text" />&emsp;
					设备编码：<input name="matrial_code" type="text" />&emsp;
					型号：<input name="matrial_type" type="text" />&emsp;
					<input class="chs-alert-search-btn" type="button" value="搜索" />
				</div>
				<div class="chs-alert-cont-scroll">
					<table class="chs-alert-cont">
						
					</table>
				</div>
				<div class="chs-alert-foot">
					<div class="chs-alert-pager">
						<input class="chs-alert-page-prev" title="上一页" type="button" value="<" />
						<input class="chs-alert-page-next" title="下一页" type="button" value=">" />
					</div>
					<div class="chs-alert-ctrl">
						<input class="chs-alert-cancel" type="button" value="取消" />
					</div>
				</div>
				<div hidden="hidden" class="chs-alert-waiting">
					<span class="chs-alert-waiting-animated">
						<span></span>
						<span></span>
						<span></span>
					</span>
				</div>
			</div>
		</div>
	</script>
	<!--弹窗列表的模板-->
	<script id="chs-alert-list-temp" type="text/html">
		<tr class="chs-alert-list-handle">
			<td>设备编码</td>
			<td>设备名称</td>
			<td>型号</td>
			<td>设备类别</td>
		</tr>
		{{each listData as val key}}
		<tr class="chs-alert-list-handle" data={{key}}>
			<td>{{val.code}}</td>
			<td>{{val.name}}</td>
			<td>{{val.model}}</td>			
			<td>{{val.typeName}}</td>
		</tr>
		{{/each}}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/guobo/asset/list">资产列表</a></li>
		<li class="active"><a href="${ctx}/guobo/asset/form?id=${asset.id}">资产<shiro:hasPermission name="guobo:asset:edit">${not empty asset.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="guobo:asset:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="asset" action="${ctx}/guobo/asset/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<form:hidden path="assetType"/>
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">展馆：</label>
			<div class="controls">
				<%-- <form:input path="exhId" htmlEscape="false" maxlength="64" /> --%>
				<sys:treeselect id="exhHall" name="exhHall.id" value="${asset.exhHall.id}" labelName="exhHall.name" labelValue="${asset.exhHall.name}"
					title="展馆" url="/guobo/exhHall/treeData" cssClass="required" notAllowSelectParent="true"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">资产编码：</label>
			<div class="controls">
				<form:input path="code" htmlEscape="false" maxlength="32"  readonly="readouly"/>
				<input id="alertHandle" type="button" value="选择"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">名称：</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="32" class="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">规格：</label>
			<div class="controls">
				<form:input path="spec" htmlEscape="false" maxlength="64" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">类型：</label>
			<div class="controls">
				<form:input path="typeName" htmlEscape="false" maxlength="64" />
				<form:hidden path="type" id="type"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">特征：</label>
			<div class="controls">
				<form:input path="feature" htmlEscape="false" maxlength="64" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">RFID：</label>
			<div class="controls">
				<form:input path="rfid" htmlEscape="false" maxlength="64" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">是否存在主RFID：</label>
			<div class="controls">
				<form:select path="isParentRfid" >
					<form:option value="" label="请选择"/>
					<form:options items="${fns:getDictList('isparentrfid')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group" id="parentRfid">
			<label class="control-label">主RFID：</label>
			<div class="controls">
				<form:input path="parentRfid" htmlEscape="false" maxlength="64" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">状态：</label>
			<div class="controls">
				<form:select path="status" class="required">
					<form:option value="" label="请选择"/>
					<form:options items="${fns:getDictList('asset_status')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">经管部门：</label>
			<div class="controls">
				<form:input path="mandeptName" htmlEscape="false" class="required"/>
				<form:hidden path="mandeptId" id="mandeptId"/>
				<%-- <sys:treeselect id="office" name="management.id" value="${asset.management.id}" labelName="management.name" labelValue="${asset.management.name}"
					title="部门" url="/sys/office/treeData?type=2" cssClass="required" notAllowSelectParent="true"/> --%>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">责任人：</label>
			<div class="controls">
				<form:input path="managerName" htmlEscape="false" class="required"/>
				<form:hidden path="managerId" id="managerId"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">电话：</label>
			<div class="controls">
				<form:input path="mobile" htmlEscape="false" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">品牌：</label>
			<div class="controls">
				<form:input path="brand" htmlEscape="false" maxlength="2" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">型号：</label>
			<div class="controls">
				<form:input path="model" htmlEscape="false" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">备注：</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="255" class="input-xxlarge "/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="guobo:asset:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
	
</html>